#pragma once

template <class Iterator, class Ref, class Ptr>
struct ReverseIterator
{
    typedef ReverseIterator<Iterator, Ref, Ptr> Self;

    ReverseIterator(Iterator it)
        : _it(it)
    {
    }

    Ref operator*()
    {
        Iterator tmp = _it; // 迭代器本身不要去改
        return *(--tmp);
    }

    Ptr operator->()
    {
        return &(operator*());
    }

    Self &operator++()
    {
        --_it;
        return *this;
    }

    Self &operator--()
    {
        ++_it;
        return *this;
    }

    bool operator!=(const Self &s)
    {
        return _it != s._it;
    }

    bool operator==(const Self &s)
    {
        return _it == s._it;
    }

    Iterator _it;
};